package com.hw.dagl.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hw.dagl.dao.impl.FrmCodeDaoImpl;
import com.hw.dagl.model.Frm_Code;
import com.hw.dagl.service.FrmCodeService;


@Service("frmCodeService")
public class FrmCodeServiceImpl implements FrmCodeService{
	
	public static List<Frm_Code> bklxFrmCodes=new ArrayList<Frm_Code>();//布控类型  下拉框
	public static List<Frm_Code> hpzlFrmCodes=new ArrayList<Frm_Code>();//号牌种类  下拉框
	public static List<Frm_Code> hpysFrmCodes=new ArrayList<Frm_Code>();//号牌颜色  下拉框
	public static List<Frm_Code> clysFrmCodes=new ArrayList<Frm_Code>();//车辆颜色  下拉框
	public static List<Frm_Code> syxzFrmCodes=new ArrayList<Frm_Code>();//使用性质  下拉框
	public static List<Frm_Code> fxlxFrmCodes=new ArrayList<Frm_Code>();//方向类型  下拉框
	public static List<Frm_Code> xzqhFrmCodes=new ArrayList<Frm_Code>();//行政区划  下拉框
	public static List<Frm_Code> sjlxFrmCodes=new ArrayList<Frm_Code>();//事件类型  下拉框
	public static Map<String,String> bklxMap=new HashMap<String,String>();//布控类型
	public static Map<String,String> hpzlMap=new HashMap<String,String>();//号牌种类
	public static Map<String,String> hpysMap=new HashMap<String,String>();//号牌颜色
	public static Map<String,String> clysMap=new HashMap<String,String>();//车辆颜色
	public static Map<String,String> syxzMap=new HashMap<String,String>();//使用性质
	public static Map<String,String> fxlxMap=new HashMap<String,String>();//方向类型
	public static Map<String,String> xzqhMap=new HashMap<String,String>();//行政区划
	public static Map<String,String> sjlxMap=new HashMap<String,String>();//事件类型
	public static final String BKLX_DMLB_CODE="0101";
	public static final String HPZL_DMLB_CODE="1007";
	public static final String HPYS_DMLB_CODE="0005";
	public static final String CLYS_DMLB_CODE="1008";
	public static final String SYXZ_DMLB_CODE="1003";
	public static final String FXLX_DMLB_CODE="1021";
	public static final String XZQH_DMLB_CODE="0033";
	public static final String SJLX_DMLB_CODE="4201";
	public static final String BKLX_XTLB_CODE="63";
	public static final String HPZL_XTLB_CODE="00";
	public static final String HPYS_XTLB_CODE="62";
	public static final String CLYS_XTLB_CODE="00";
	public static final String SYXZ_XTLB_CODE="00";
	public static final String FXLX_XTLB_CODE="61";
	public static final String XZQH_XTLB_CODE="00";
	public static final String SJLX_XTLB_CODE="65";
	@SuppressWarnings("rawtypes")
	Map[] mapArr={bklxMap,hpzlMap,hpysMap,clysMap,syxzMap,fxlxMap,xzqhMap,sjlxMap};
	String[] dmlbCodeArr={BKLX_DMLB_CODE,HPZL_DMLB_CODE,HPYS_DMLB_CODE,CLYS_DMLB_CODE,SYXZ_DMLB_CODE,FXLX_DMLB_CODE,XZQH_DMLB_CODE,SJLX_DMLB_CODE};
	String[] xtlbCodeArr={BKLX_XTLB_CODE,HPZL_XTLB_CODE,HPYS_XTLB_CODE,CLYS_XTLB_CODE,SYXZ_XTLB_CODE,FXLX_XTLB_CODE,XZQH_XTLB_CODE,SJLX_XTLB_CODE};
	
	@Resource
	private FrmCodeDaoImpl frmCodeDao;
	
	@SuppressWarnings("unchecked")
	@Override
	public void queryFrmCodeByMap() {
		Frm_Code frmCode=new Frm_Code();
		for(int i=0,length=dmlbCodeArr.length;i<length;i++){
			frmCode.setDmlb(dmlbCodeArr[i]);
			frmCode.setXtlb(xtlbCodeArr[i]);
			List<Frm_Code> frmCodes=frmCodeDao.selectEntityList(frmCode);
			if(i==0){
				bklxFrmCodes=frmCodes;
			}else if(i==1){
				hpzlFrmCodes=frmCodes;
			}else if(i==2){
				hpysFrmCodes=frmCodes;
			}else if(i==3){
				clysFrmCodes=frmCodes;
			}else if(i==4){
				syxzFrmCodes=frmCodes;
			}else if(i==5){
				fxlxFrmCodes=frmCodes;
			}else if(i==6){
				xzqhFrmCodes=frmCodes;
			}else if(i==7){
				sjlxFrmCodes=frmCodes;
			}
			disposeFrmCodes(frmCodes,frmCode,mapArr[i]);
		}
	}
	
	//处理查询返回的结果值
	public static void disposeFrmCodes(List<Frm_Code> frmCodes,Frm_Code frmCode,Map<String,String> map){
		for(int i=0,size=frmCodes.size();i<size;i++){
			frmCode=frmCodes.get(i);
			String dmz=frmCode.getDmz();//代码值
			String dmsm1=frmCode.getDmsm1();//代码属性1
			//防止数据库中配置了重复的dmz
			if(!map.containsKey(dmz)){
				map.put(dmz, dmsm1);
			}
		}
	}

	
	
}
